package mygame;

import com.jme3.scene.Node;

public abstract class LayerSwitcher {

    public static boolean switchToLayer(int layerNum) {
	VoxelLayer voxelLayer = DataStore.worldStateNode.getVoxelGrid().getVoxelLayer(layerNum);
	if(voxelLayer == null)
	    return false;

	//it's not very efficient, but it's freaking awesome
	for(Node constructHubNode : DataStore.worldStateNode.getAllConstructHubNodes())
	    constructHubNode.detachAllChildren();
	for(Voxel voxel : voxelLayer.getVoxels())
	    voxel.getOccupyingConstruct().reattachToSavedParent();
	return true;
    }
}
